/* 
 * File:   Datum.h
 * Author: pkv
 *
 * Created on September 9, 2009, 9:16 PM
 */

#ifndef MCVDATUM_H
#define	MCVDATUM_H

#include <string>
#include "mcvcommon.h"

namespace MCV
{

class Array;

class Datum {    
private:
    int _type;
    union {
        Array* ptr;
        mcvint i;
        mcvfloat d;
        mcvuchar c;
//        std::string s;
    } _data;
public:
	Datum(); // defaults to byte with value 0
    Datum(mcvuchar c);
    Datum(mcvfloat d);
    Datum(mcvint i);
    Datum(Array* ptr);
    Datum(const Datum& orig);
	~Datum();

	int type();

    operator mcvint();
    operator mcvfloat();
    operator mcvuchar();
    operator Array*();

	Datum& operator= (const mcvint& i);
	Datum& operator= (const mcvfloat& f);
	Datum& operator= (const mcvuchar& u);
	Datum& operator= (Array* ptr);
	Datum& operator= (const Datum& rhs);

	void clear();

};

inline int raw_type_id(Datum& v)
{
	return MCVGENERIC;
}

inline int type_id(Datum& v)
{
	return v.type();
}

}

#endif	/* MCVDATUM_H */

